home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / 80x0992d.zip / COPPER.TXT < prev    next >
Text File  |  1992-09-30  |  2KB  |  75 lines

  1. By Craig Allsop
  2.  
  3. I figured I might as well give everyone the macros from
  4. my source that display the copper bars. (They were written for Tasm, 
  5. Ideal mode - but are easily converted) - I reveal all!
  6.  
  7. macro   waithorz                ; DX = 3DAh!
  8.         local   a,b
  9. a:      in      al,dx
  10.         rcr     al,1
  11.         jc      a
  12. b:      in      al,dx
  13.         rcr     al,1
  14.         jnc     b
  15. endm
  16.  
  17. macro   waitvert
  18.         local   a,b
  19. a:      in      al,dx
  20.         test    al,8
  21.         jnz     a
  22. b:      in      al,dx
  23.         test    al,8
  24.         jz      b
  25. endm
  26.  
  27. macro   copper                  ; SI = Colour table, CX = # of Colours
  28.         local   a               ; BL = Palette to change
  29.         mov     ah,0c9h
  30.         mov     dl,3
  31. a:      mov     dl,0c8h
  32.         mov     al,bl
  33.         out     dx,al           ; Select palette
  34.         inc     dl
  35.         outsb
  36.         outsb                   ; Send first 2 values
  37.         lodsb                   ; Get next one ready
  38.         mov     bh,al           ; and hang onto it
  39.         mov     dl,0dah
  40.         waithorz                ; Wait for the horz. retrace
  41.         mov     dl,ah
  42.         mov     al,bh
  43.         out     dx,al           ; Send last value (Causes static!)
  44.         dec     cx
  45.         jnz     a               ; Continue...
  46. endm
  47.  
  48.  
  49. To use them, requires a 'waitvert' before using 'copper' to execute it, and
  50. 'waitvert' requires dx = 3dah. Simple really. Eg:
  51.  
  52.         mov     si, <address of palette>
  53.         mov     cx, <number of colours/lines>
  54.         mov     bl, <palette to change>
  55.         mov     dx, 3dah
  56.         waitvert
  57.         copper
  58.  
  59. You will notice that I send two values before waiting for the retrace, because
  60. the VGA only loads them into a buffer, and only updates the palette registers
  61. when it gets the last value, which is also when you get the static 'dot'
  62. appearing on the screen. Since I'm doing it this way, on slow machines it works
  63. perfectly, and on faster machines you get static on the right side of the
  64. screen, but you can remove the overscan on the right side to fix that problem.
  65.  
  66. Regards,
  67. Craig.
  68.  
  69. (If anyone uses the above macros, or modify the above code for suitable
  70. functions in another lanugage, then be my guest, but please give credit where
  71. its due, and mention my name or my alias 'Daemon' - the above macros must
  72. conatin this paragraph in any source and are Public Domain in all other
  73. respects)
  74.  
  75.